const express=require('express')
const fs=require('fs')
const path=require('path')
const router=express.Router()
router.get('/list',(req,res)=>{
    console.log('=======学生模块>学生列表============');
})
router.post('/add',(req,res)=>{
    fs.readFile(path.join(__dirname,'../','data','students.json'),"utf-8",(err,data)=>{
        if(!err){
            let students=JSON.parse(data)
            students.push(req.body)
            fs.writeFile(path.join(__dirname,'../','data','students.json'),JSON.stringify(students),(err,data)=>{
                if(!err){
                    res.send({
                        code:1,
                        message:'增加成功'
                    })
                }
            })
        }
    })
})
router.delete('/del',(req,res)=>{
    console.log('=======学生模块>删除学生============');
})
router.put('/modify',(req,res)=>{
    console.log('=======学生模块>学生学生============');
})
module.exports=router